package com.hliushi.oauth2.pojo;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.springframework.security.core.GrantedAuthority;
import org.springframework.security.core.userdetails.UserDetails;

import java.util.Collection;
import java.util.List;

/**
 * @author llhuang10
 */
@Data
@AllArgsConstructor
@NoArgsConstructor
public class User implements UserDetails {


    // https://www.baidu.com/?code=7iO3b0
    // code=7iO3b0 授权码


    // http://localhost:8080/oauth/authorize?responsetype=code&client_id=admin&redirect_uri=http://www.baidu.com&scope=all
    private static final long serialVersionUID = -8099652580581032793L;
    private String username;

    private String password;

    private List<GrantedAuthority> authorities;

    @Override
    public Collection<? extends GrantedAuthority> getAuthorities() {
        return authorities;
    }

    @Override
    public String getPassword() {
        return this.password;
    }

    @Override
    public String getUsername() {
        return this.username;
    }

    @Override
    public boolean isAccountNonExpired() {
        return true;
    }

    /*
     * 是否不上锁
     *
     * @return false 上锁,  true 不上锁
     */
    @Override
    public boolean isAccountNonLocked() {
        return true;
    }

    @Override
    public boolean isCredentialsNonExpired() {
        return true;
    }

    @Override
    public boolean isEnabled() {
        return true;
    }
}
